<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Toolbox">
    <Style TargetType="{x:Type local:Toolbox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Toolbox}">
                    <Grid>
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <StackPanel IsItemsHost="True" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" />
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentPresenter Margin="3" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:ToolboxCategory}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxCategory}">
                    <Grid Background="Transparent">
                        <Rectangle Width="40" Height="40" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" RadiusX="2" RadiusY="2" />
                        <ContentPresenter Margin="{TemplateBinding Padding}" Content="{TemplateBinding MainItem}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                        <Canvas Name="ExpanderCanvas" Visibility="Collapsed">
                            <Path Width="5.57359" Height="8.70267" Canvas.Right="6" Canvas.Bottom="6" Stretch="Fill" Fill="#FF5E5E5E" Data="F1 M 44.1443,39.0107L 38.5707,34.6594L 38.5707,43.362L 44.1443,39.0107 Z "/>
                        </Canvas>
                        <Popup Name="Popup" Placement="Right" IsOpen="{TemplateBinding IsExpanded}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade" HorizontalOffset="-2">
                            <Border Name="SubmenuBorder" SnapsToDevicePixels="True" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" CornerRadius="2" Padding="2,0,0,0">
                                <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
                        </Trigger>
                        <Trigger Property="IsExpanderVisible" Value="True">
                            <Setter TargetName="ExpanderCanvas" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                    </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
        <Setter Property="BorderBrush" Value="DarkGray" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Width" Value="45" />
        <Setter Property="Height" Value="45" />
    </Style>

    <Style TargetType="{x:Type local:ToolboxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxItem}">
                    <Grid>
                        <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" RadiusX="2" RadiusY="2" />
                        <Rectangle x:Name="gloss" Fill="White" Opacity="0.4" Margin="2" RenderTransformOrigin="0.5,0">
                            <Rectangle.RenderTransform>
                                <ScaleTransform ScaleX="1" ScaleY="0.5" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="gloss" Property="Visibility" Value="Hidden" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
        <Setter Property="BorderBrush" Value="DarkGray" />
        <Setter Property="Width" Value="40" />
        <Setter Property="Height" Value="40" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Margin" Value="2" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
